<template>
  <el-form :model="form" label-width="120px">
    <el-form-item label="用户名">
      <el-input v-model="form.username" />
    </el-form-item>

    <el-form-item label="密码">
      <el-input v-model="form.password" />
    </el-form-item>


    <el-form-item>
      <el-button type="primary" @click="onSubmit">提交</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script  setup>
import { ref } from 'vue'
import axios from '@/util/request'


// do not use same name with ref
const form = ref({
  username: '',
  password: '',
})

const onSubmit = () => {
  let url = "/admin/user/loginByUsernameAndPassword";
  axios.post(url,form.value).then(function (result){
    console.log(result)
    localStorage.setItem("token",result.data);
  })
}
</script>

<style scoped>

</style>
